home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 4.8 KB | 183 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Utils.h
- // Release Version: $ ODF 2 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef UTILS_H
- #define UTILS_H
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWINK_H
- #include "FWInk.h"
- #endif
-
- #ifndef FWSTYLE_H
- #include "FWStyle.h"
- #endif
-
- #ifndef SLGRDEF_H
- #include "SLGrDef.h"
- #endif
-
- #ifndef FWSUSINK_H
- #include "FWSUSink.h"
- #endif
-
- // ----- FOundation Layer -----
-
- #ifndef FWSTDDEF_H
- #include "FWStdDef.h"
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- class FW_CGraphicContext;
- class FW_CRect;
- class FW_CStorageUnitSink;
- class FW_CCloneInfo;
-
- class CDrawPart;
-
- //========================================================================================
- // Class CGrid
- //========================================================================================
- // index, row and column are 0 based
- //
- // Index Example 0 | 1 | 2
- // ---------
- // 3 | 4 | 5
- //
-
- class CGrid
- {
- public:
- CGrid(unsigned short rows, unsigned short columns,
- const FW_CPoint& position,
- const FW_CPoint& cellInterior,
- FW_Fixed penSize);
-
- FW_Boolean FindCell(const FW_CPoint& where, unsigned long& index) const;
- FW_Boolean FindCell(const FW_CPoint& where, unsigned short& row, unsigned short& column) const;
-
- void GetCellInterior(unsigned short row, unsigned short column, FW_CRect& rect) const;
- void GetCellInterior(unsigned long index, FW_CRect& rect) const;
-
- void GetCellExterior(unsigned short row, unsigned short column, FW_CRect& rect) const;
- void GetCellExterior(unsigned long index, FW_CRect& rect) const;
-
- void GetExteriorGridRect(FW_CRect& rect) const;
- void GetInteriorGridRect(FW_CRect& rect) const;
-
- unsigned long GetIndex(unsigned short row, unsigned short column) const
- {return row * fColumns + column;}
-
- void GetRowColumn(unsigned long index, unsigned short& row, unsigned short& column) const;
-
- void DrawGridBorders(FW_CGraphicContext& gc, const FW_CInk& ink = FW_kNormalInk, const FW_CStyle& style = FW_kNormalStyle);
-
- private:
- unsigned short fRows;
- unsigned short fColumns;
- FW_CPoint fPosition;
- FW_CPoint fCellSize;
- FW_Fixed fHalfPenSize;
- };
-
- //========================================================================================
- // Class CWidget
- //========================================================================================
-
- class CWidget
- {
- public:
- CWidget(FW_ResourceID resID);
- ~CWidget();
-
- void Render(FW_CGraphicContext& gc, const FW_CRect& rect);
-
- private:
- FW_ResourceID fResID;
-
- };
-
- //========================================================================================
- // class CDrawReadableStream
- //========================================================================================
- // This is a hack until I can pass data through the archiver
-
- class CDrawReadableStream : public FW_CReadableStream
- {
- public:
-
- FW_DECLARE_AUTO(CDrawReadableStream)
-
- CDrawReadableStream(Environment* ev,
- CDrawPart* drawPart,
- FW_ORandomAccessSink* sink,
- FW_OStorageUnitSink* suSink,
- FW_CCloneInfo* cloneInfo);
- virtual ~CDrawReadableStream();
-
- Environment* GetEnvironment() const
- {return fEnvironment;}
- CDrawPart* GetDrawPart() const
- {return fDrawPart;}
- FW_CCloneInfo* GetCloneInfo() const
- {return fCloneInfo;}
- ODStorageUnitView* GetStorageUnitView() const
- {return fSUSink->GetStorageUnitView(fEnvironment);}
- private:
- Environment* fEnvironment;
- CDrawPart* fDrawPart;
- FW_OStorageUnitSink* fSUSink;
- FW_CCloneInfo* fCloneInfo;
- };
-
- //========================================================================================
- // class CDrawReadableStream
- //========================================================================================
- // This is a hack until I can pass data through the archiver
-
- class CDrawWritableStream : public FW_CWritableStream
- {
- public:
-
- FW_DECLARE_AUTO(CDrawWritableStream)
-
- CDrawWritableStream(Environment* ev,
- FW_ORandomAccessSink* sink,
- FW_OStorageUnitSink* suSink,
- FW_CCloneInfo* cloneInfo);
- virtual ~CDrawWritableStream();
-
- Environment* GetEnvironment() const
- {return fEnvironment;}
- FW_CCloneInfo* GetCloneInfo() const
- {return fCloneInfo;}
- ODStorageUnitView* GetStorageUnitView() const
- {return fSUSink->GetStorageUnitView(fEnvironment);}
- private:
- Environment* fEnvironment;
- FW_OStorageUnitSink* fSUSink;
- FW_CCloneInfo* fCloneInfo;
- };
-
- #endif
-